/*
	创建socket.io服务器
*/

var http = require('http');
var sio = require('socket.io');
var fs = require('fs');

var server = http.createServer(function(req, res){
	res.writeHead(200, {'Content-type' : 'text/html'});
	res.end(fs.readFileSync('./2_client.html'));
}).listen(1337);


var socketSer = sio.listen(server);

socketSer.on('connection', function(socket){

	console.log("客户端建立连接");

	socket.send('你好。');

	socket.on('message', function(msg){
		console.log('接收到一个消息：', msg);
	});

	socket.on('disconnect', function(){
		console.log('客户端断开连接');
	});
});

